package com.molichuxing.services.exception;

import java.util.HashMap;
import java.util.Map;

public enum PermissionExceptionCodeEnum {
	/**
	 * 账号禁用
	 */
	DISABLE(30401, "用户名被禁用，请联系管理员重新开"),
	/**
	 * 账号已删除
	 */
	DELETE(30402, "账号删除"),
	/**
	 * 账号密码错误
	 */
	PWD_ERROR(30403, "账号密码错误"),
	/**
	 * 账号不存在
	 */
	NOT_FOUND(30404, "账号不存在"),

	NOT_SYSTEM_PERMISSION(30405, "您无系统权限，请联系管理员开通相关权限");

	final static private Map<Integer, PermissionExceptionCodeEnum> MAP = new HashMap<Integer, PermissionExceptionCodeEnum>() {
		private static final long serialVersionUID = -8414553247670306999L;
		{
			PermissionExceptionCodeEnum[] enums = PermissionExceptionCodeEnum.values();
			for (PermissionExceptionCodeEnum OrderExceptionCodeEnum : enums) {
				put(OrderExceptionCodeEnum.getCode(), OrderExceptionCodeEnum);
			}
		}
	};

	public static PermissionExceptionCodeEnum getEnum(Integer code) {
		return MAP.get(code);
	}

	public static String getEnumDesc(Integer code) {
		PermissionExceptionCodeEnum OrderExceptionCodeEnum = MAP.get(code);
		if (OrderExceptionCodeEnum != null) {
			return OrderExceptionCodeEnum.getMessage();
		}
		return "";
	}

	private Integer code;

	private String message;

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	private PermissionExceptionCodeEnum(Integer code, String message) {
		this.code = code;
		this.message = message;
	}
}
